package com.spddr.pmos.jpa;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import cn.seqdata.jpa.JpaGeneratedObject;
import cn.seqdata.jpa.JpaNoGeneratedObject;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "user_info")
public class User extends JpaNoGeneratedObject {
	private static final long serialVersionUID = 1L;

	private Company company;

	private String username;
	private String password;
	private String salt;
	private byte[] privkey;
	private byte[] pubkey;
	private String email;
	private String mobile;
	private String avatar;

	public User(Long id) {
		super(id);
	}

	public User(Long id, String name) {
		super(id, name);
	}

	public User(JpaGeneratedObject object) {
		super(object);
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "company", nullable = false)
	@JsonSerialize(using = cn.seqdata.jackson.ObjectSerializer.IdName.class)
	public Company getCompany() {
		return this.company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	@Column(name = "username", length = 20)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password", length = 64)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "salt", length = 6)
	public String getSalt() {
		return this.salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	@Column(name = "privkey")
	public byte[] getPrivkey() {
		return this.privkey;
	}

	public void setPrivkey(byte[] privkey) {
		this.privkey = privkey;
	}

	@Column(name = "pubkey")
	public byte[] getPubkey() {
		return this.pubkey;
	}

	public void setPubkey(byte[] pubkey) {
		this.pubkey = pubkey;
	}

	@Column(name = "email", length = 80)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "mobile", length = 11)
	public String getMobile() {
		return this.mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Column(name = "avatar")
	public String getAvatar() {
		return this.avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
}